using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._LayersandTableViews
{
    /// <summary>
    /// <para>Make Query Table</para>
    /// <para>Applies an SQL query to a database, and the results are represented in either a layer or table view. The query can be used to join several tables or return a subset of fields or rows from the original data in the database.</para>
    /// <para>将 SQL 查询应用于数据库，结果以图层或表视图表示。该查询可用于联接多个表，或从数据库中的原始数据返回字段或行的子集。</para>
    /// </summary>    
    [DisplayName("Make Query Table")]
    public class MakeQueryTable : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public MakeQueryTable()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_table">
        /// <para>Input Tables</para>
        /// <para><xdoc>
        ///   <para>The name of the table or tables to be used in the query. If several tables are listed, the Expression parameter can be used to define how they will be joined.</para>
        ///   <para>The input table can be from a geodatabase or a database connection.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>要在查询中使用的一个或多个表的名称。如果列出了多个表，则可以使用 Expression 参数来定义它们的联接方式。</para>
        ///   <para>输入表可以来自地理数据库或数据库连接。</para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_out_table">
        /// <para>Table Name</para>
        /// <para>The name of the layer or table view that will be created.</para>
        /// <para>将创建的图层或表视图的名称。</para>
        /// </param>
        /// <param name="_in_key_field_option">
        /// <para>Key Field Options</para>
        /// <para><xdoc>
        ///   <para>Specifies how an ObjectID field will be generated (if at all) for the query. Layers and table views in ArcGIS require an ObjectID field. An ObjectID field is an integer field that uniquely identifies rows in the data being used. The default is Use key fields (USE_KEY_FIELDS in Python).</para>
        ///   <bulletList>
        ///     <bullet_item>Use key fields—Specified fields in the Key Fields parameter will be used to uniquely identify a row in the output table. This can be a single field or multiple fields, which, when combined, uniquely identify a row in the output table. If no fields are specified in the key fields list, the Generate a key field option (ADD VIRTUAL_KEY_FIELD in Python) is automatically applied.</bullet_item><para/>
        ///     <bullet_item>Generate a key field—If no key fields have been specified, an ObjectID that uniquely identifies each row in the output table will be generated.</bullet_item><para/>
        ///     <bullet_item>No key field—No ObjectID field will be generated. Selections will not be supported for the table view.
        ///     <para>If there is already a field of type ObjectID in the fields list, it will be used as the ObjectID even if this option is chosen.</para>
        ///     </bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何为查询生成 ObjectID 字段（如果有）。ArcGIS 中的图层和表视图需要 ObjectID 字段。ObjectID 字段是一个整数字段，用于唯一标识正在使用的数据中的行。默认值为“使用关键字段”（在 Python 中为 USE_KEY_FIELDS）。</para>
        ///   <bulletList>
        ///     <bullet_item>使用关键字段 - 关键字段参数中的指定字段将用于唯一标识输出表中的行。这可以是单个字段，也可以是多个字段，当它们组合在一起时，可以唯一地标识输出表中的一行。如果键字段列表中未指定任何字段，则会自动应用“生成键字段”选项（在 Python 中为 ADD VIRTUAL_KEY_FIELD）。</bullet_item><para/>
        ///     <bullet_item>生成键字段 - 如果未指定键字段，则将生成唯一标识输出表中每一行的 ObjectID。</bullet_item><para/>
        /// <bullet_item>无键字段 - 不会生成任何 ObjectID 字段。表视图将不支持选择。
        ///     <para>如果字段列表中已有 ObjectID 类型的字段，则即使选择此选项，该字段也将用作 ObjectID。</para>
        ///     </bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        public MakeQueryTable(List<object> _in_table, object _out_table, _in_key_field_option_value _in_key_field_option)
        {
            this._in_table = _in_table;
            this._out_table = _out_table;
            this._in_key_field_option = _in_key_field_option;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Make Query Table";

        public override string CallName => "management.MakeQueryTable";

        public override List<string> AcceptEnvironments => ["workspace"];

        public override object[] ParameterInfo => [_in_table, _out_table, _in_key_field_option.GetGPValue(), _in_key_field, _in_field, _where_clause];

        /// <summary>
        /// <para>Input Tables</para>
        /// <para><xdoc>
        ///   <para>The name of the table or tables to be used in the query. If several tables are listed, the Expression parameter can be used to define how they will be joined.</para>
        ///   <para>The input table can be from a geodatabase or a database connection.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>要在查询中使用的一个或多个表的名称。如果列出了多个表，则可以使用 Expression 参数来定义它们的联接方式。</para>
        ///   <para>输入表可以来自地理数据库或数据库连接。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Tables")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public List<object> _in_table { get; set; }


        /// <summary>
        /// <para>Table Name</para>
        /// <para>The name of the layer or table view that will be created.</para>
        /// <para>将创建的图层或表视图的名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Table Name")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _out_table { get; set; }


        /// <summary>
        /// <para>Key Field Options</para>
        /// <para><xdoc>
        ///   <para>Specifies how an ObjectID field will be generated (if at all) for the query. Layers and table views in ArcGIS require an ObjectID field. An ObjectID field is an integer field that uniquely identifies rows in the data being used. The default is Use key fields (USE_KEY_FIELDS in Python).</para>
        ///   <bulletList>
        ///     <bullet_item>Use key fields—Specified fields in the Key Fields parameter will be used to uniquely identify a row in the output table. This can be a single field or multiple fields, which, when combined, uniquely identify a row in the output table. If no fields are specified in the key fields list, the Generate a key field option (ADD VIRTUAL_KEY_FIELD in Python) is automatically applied.</bullet_item><para/>
        ///     <bullet_item>Generate a key field—If no key fields have been specified, an ObjectID that uniquely identifies each row in the output table will be generated.</bullet_item><para/>
        ///     <bullet_item>No key field—No ObjectID field will be generated. Selections will not be supported for the table view.
        ///     <para>If there is already a field of type ObjectID in the fields list, it will be used as the ObjectID even if this option is chosen.</para>
        ///     </bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定如何为查询生成 ObjectID 字段（如果有）。ArcGIS 中的图层和表视图需要 ObjectID 字段。ObjectID 字段是一个整数字段，用于唯一标识正在使用的数据中的行。默认值为“使用关键字段”（在 Python 中为 USE_KEY_FIELDS）。</para>
        ///   <bulletList>
        ///     <bullet_item>使用关键字段 - 关键字段参数中的指定字段将用于唯一标识输出表中的行。这可以是单个字段，也可以是多个字段，当它们组合在一起时，可以唯一地标识输出表中的一行。如果键字段列表中未指定任何字段，则会自动应用“生成键字段”选项（在 Python 中为 ADD VIRTUAL_KEY_FIELD）。</bullet_item><para/>
        ///     <bullet_item>生成键字段 - 如果未指定键字段，则将生成唯一标识输出表中每一行的 ObjectID。</bullet_item><para/>
        /// <bullet_item>无键字段 - 不会生成任何 ObjectID 字段。表视图将不支持选择。
        ///     <para>如果字段列表中已有 ObjectID 类型的字段，则即使选择此选项，该字段也将用作 ObjectID。</para>
        ///     </bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Key Field Options")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _in_key_field_option_value _in_key_field_option { get; set; }

        public enum _in_key_field_option_value
        {
            /// <summary>
            /// <para>Use key fields</para>
            /// <para>Use key fields—Specified fields in the Key Fields parameter will be used to uniquely identify a row in the output table. This can be a single field or multiple fields, which, when combined, uniquely identify a row in the output table. If no fields are specified in the key fields list, the Generate a key field option (ADD VIRTUAL_KEY_FIELD in Python) is automatically applied.</para>
            /// <para>使用关键字段 - 关键字段参数中的指定字段将用于唯一标识输出表中的行。这可以是单个字段，也可以是多个字段，当它们组合在一起时，可以唯一地标识输出表中的一行。如果键字段列表中未指定任何字段，则会自动应用“生成键字段”选项（在 Python 中为 ADD VIRTUAL_KEY_FIELD）。</para>
            /// </summary>
            [Description("Use key fields")]
            [GPEnumValue("USE_KEY_FIELDS")]
            _USE_KEY_FIELDS,

            /// <summary>
            /// <para>Generate a key field</para>
            /// <para>Generate a key field—If no key fields have been specified, an ObjectID that uniquely identifies each row in the output table will be generated.</para>
            /// <para>生成键字段 - 如果未指定键字段，则将生成唯一标识输出表中每一行的 ObjectID。</para>
            /// </summary>
            [Description("Generate a key field")]
            [GPEnumValue("ADD_VIRTUAL_KEY_FIELD")]
            _ADD_VIRTUAL_KEY_FIELD,

            /// <summary>
            /// <para>No key field</para>
            /// <para>No key field—No ObjectID field will be generated. Selections will not be supported for the table view.</para>
            /// <para>无键字段 - 不会生成任何 ObjectID 字段。表视图将不支持选择。</para>
            /// </summary>
            [Description("No key field")]
            [GPEnumValue("NO_KEY_FIELD")]
            _NO_KEY_FIELD,

        }

        /// <summary>
        /// <para>Key Fields</para>
        /// <para><xdoc>
        ///   <para>A field or combination of fields that will be used to uniquely identify a row in the query. This parameter is used only when the Key Field Options parameter is set to Use Key Fields.</para>
        ///   <para>The Add Field button, which is used only in ModelBuilder, allows you to add expected fields so you can complete the dialog box and continue to build your model.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>将用于唯一标识查询中的行的字段或字段组合。仅当“关键字段选项”参数设置为“使用关键字段”时，才使用此参数。</para>
        ///   <para>添加字段按钮（仅在模型构建器中使用）可用于添加预期字段，以便完成对话框并继续构建模型。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Key Fields")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _in_key_field { get; set; } = null;


        /// <summary>
        /// <para>Fields</para>
        /// <para>The fields to include in the layer or table view. If an alias is set for a field, this is the name that appears. If no fields are specified, all fields from all tables are included. If a Shape field is added to the field list, the result is a layer; otherwise it is a table view.</para>
        /// <para>要包含在图层或表视图中的字段。如果为字段设置了别名，则显示此名称。如果未指定任何字段，则包括所有表中的所有字段。如果将“形状”字段添加到字段列表中，则结果为图层;否则，它是表视图。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Fields")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _in_field { get; set; } = null;


        /// <summary>
        /// <para>Expression</para>
        /// <para>An SQL expression used to select a subset of records.</para>
        /// <para>用于选择记录子集的 SQL 表达式。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Expression")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _where_clause { get; set; } = null;


        public MakeQueryTable SetEnv(object workspace = null)
        {
            base.SetEnv(workspace: workspace);
            return this;
        }

    }

}